package com.nutricia.biz.impl;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nutricia.common.api.request.AddMeetingReq;
import com.nutricia.common.api.result.ReturnDataRes;
import com.nutricia.common.lang.ServiceCallBack;
import com.nutricia.common.util.CheckUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 会议相关控制器实现类
* @author wangzl
* @date 2018年4月25日
 */
@Api(value="/meeting", description="会议相关接口")
@RestController
@RequestMapping("/meeting")
public class MeetingController extends AbstractFacadeImpl{

	@ApiOperation(value="addMeeting", notes="新增会议")
	@RequestMapping(value="addMeeting", method=RequestMethod.POST)
	public ReturnDataRes addMeeting(@RequestBody AddMeetingReq addMeetingReq) {
		 final ReturnDataRes result = new ReturnDataRes();
		 return serviceExecuteTemplate.executeService(result, new ServiceCallBack() {
	            @Override
	            public void check() throws Exception {
	            	 CheckUtil.isNotBlank(addMeetingReq.getmName(),"会议名称为空！");
	            	 CheckUtil.isNotBlank(addMeetingReq.getmStartDate().toString(),"会议开始时间为空！");
	            	 CheckUtil.isNotBlank(addMeetingReq.getmEndDate().toString(),"会议结束时间为空！");
	            	 CheckUtil.isNotBlank(addMeetingReq.getmHostCity(),"会议举办城市为空！");
	            	 CheckUtil.isNotBlank(addMeetingReq.getHotel(),"会议举办酒店为空！");
	            	 CheckUtil.isNotBlank(addMeetingReq.getAddress(),"会议酒店地址为空！");
	            	 CheckUtil.isNotBlank(addMeetingReq.getContacts(),"会议联系人为空！");
	            	 CheckUtil.isNotBlank(addMeetingReq.getContactNumber(),"会议联系人电话为空！");
	            }

	            @Override
	            public void doService() throws Exception {
	            	//新增会议
	            	String meetingId = meetingService.addMeeting(addMeetingReq);
	            	result.setData(meetingId);
	                if(meetingId != null) {
	                	result.setMessage("会议新增成功！");
	 	                result.setCode("0000");
	                }else {
	                	result.setMessage("会议新增失败！");
	 	                result.setCode("1111");
	                }
	                result.setSuccess(true);
	            }
	        });
	}

}
